//
//  HWSubscribeButtonCell.m
//  HuaWan
//
//  Created by HuaWan on 2022.
//  Copyright ©2022年 HuaWan. All rights reserved.
//

#import "HWSubscribeButtonCell.h"

@implementation HWSubscribeButtonCell

+ (id)instanceView {
    NSArray* nibView =  [[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:self options:nil];
    return [nibView objectAtIndex:0];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setData:(id)data delegate:(id)delegate {
    _delegate = delegate;
    
    if ([data isKindOfClass:[NSDictionary class]]) {
        if ([data[@"data"] isKindOfClass:[HWSubscribeButtonCellModel class]]) {
            HWSubscribeButtonCellModel *model = data[@"data"];
            [_myButton setTitle:model.title forState:UIControlStateNormal];
        }
    }
    
}

- (IBAction)buttonAction:(UIButton *)sender {
    if (_delegate && [_delegate respondsToSelector:@selector(subscribeButtonCell:button:)]) {
        [_delegate subscribeButtonCell:self button:sender];
    }
}

@end


#pragma mark - Model

@implementation HWSubscribeButtonCellModel

+ (HWSubscribeButtonCellModel *)ittemModelWithTitle:(NSString *)title {
    HWSubscribeButtonCellModel *model = [HWSubscribeButtonCellModel new];
    model.title = kSafeString(title);
    return model;
}

@end
